package eclipse.weibo.modle;

import java.util.ArrayList;
import java.util.List;

import org.eclipse.swt.custom.ScrolledComposite;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;

import weibo4j.Status;

public class StatusViewer extends Composite {
    private List<StatusWindow> list = new ArrayList<StatusWindow>();
    private Composite parent;

    public StatusViewer(Composite parent, int style) {
        super(parent, style);
        FillLayout lay = new FillLayout();
        parent.setLayout(lay);

        ScrolledComposite scrolledComposite = new ScrolledComposite(parent, 768);
        scrolledComposite.setBackground(getDisplay().getSystemColor(9));

        this.parent = new Composite(scrolledComposite, 0);
        scrolledComposite.setContent(this.parent);
        this.parent.setBackground(getDisplay().getSystemColor(3));
        this.parent.setLayout(new GridLayout(1, true));
        GridData data = new GridData(1808);
        this.parent.setLayoutData(data);

        scrolledComposite.setExpandHorizontal(true);
        scrolledComposite.setExpandVertical(true);

        this.parent.setSize(this.parent.computeSize(-1, -1));
        scrolledComposite.setMinSize(this.parent.computeSize(-1, -1));
    }

    public void setStatus(List<Status> l) {
        for (int i = 0; i < l.size(); ++i) {
            //GridData data = new GridData(super.getParent().getClientArea().width, 30);
            StatusWindow sw = new StatusWindow(this.parent, 2048);
            sw.setStatus(l.get(i));
            this.list.add(sw);
        }
    }
}
